< previous page page_66 next page >

Page 66
Of course, every project should have an Exit button. Enter the following line for the Exit button:
Private Sub cmdExit_Click()
    '
    ' end program
    '
    rs.Close
    db.Close
    Set rs = Nothing
    Set db = Nothing
    Unload Me
    '
End Sub
When you have completed the coding, save the form as TBSEEK.FRM and the project as TBSEEK.VBP, and then run the program. Click the Title, ISBN, or Publisher buttons to set the index and load the list box. Note that each time you select a different button, the list is loaded in a different order. After the list is loaded, click the Seek button to perform an indexed search on the data table. If you enter a value that is in the index, the program reports the title of the book in a message box; otherwise, you see an error message. See Figure 3.7 for an example.
0066-01.jpg
Figure 3.7.
Testing the TbSeek Demonstration Project.
Limitations of the Table-Type Recordset Data Object
Even though the Visual Basic Table-type Recordset object provides the fastest search speed of any of the data objects, it also has certain drawbacks. You cannot sort a table; you can't use the Table object when accessing ODBC data sources; and you can't use the Visual Basic data control to access a Table object.
Tables Cannot Use Bookmarks, Sorts, or Filters
Unlike Dynasets and Snapshots, Visual Basic Table objects cannot be sorted, filtered, or have Bookmarks set. Instead of sorting the data, you can use Index objects to establish the order

 
< previous page page_66 next page >

If you like this book, buy it!